package utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;

public class GNDUtils {

	private static boolean logEnabled = false;

	public static void logError(String message) {

		if (!logEnabled)
			return;
		
		File logfile;
		PrintStream log;

		try {
			File logfolder = new File("log");
			logfolder.mkdir();
			logfile = new File("log/logfileDatensatz.txt");
			final boolean append = true;

			FileOutputStream logOS = new FileOutputStream(logfile, append);

			log = new PrintStream(logOS);
			
			log.print("Fehler:" + message);
			
			log.println();
			
			log.close();
		} catch (Exception e1) {
			// Gefährlich, aber wohl sinnvoll, da nur ein Logversuch
			// in nicht allzu wichtigen Situationen.
			e1.printStackTrace();
		}
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	public static void setLogEnabled(boolean logEnabled) {
		GNDUtils.logEnabled = logEnabled;
	}

}
